import intro.ex9.*;
import java.awt.Image;

/**
 * 
 * @author danalmog
 *
 */
public class Human extends SpaceShip{  
	
	private int shotCounter;
    
	/**
	 * construct a new human SpaceShip.
	 */
	public Human(){
        super();
        shotCounter=TURNS_PER_SHOOT;
    }

    @Override
    public void doAction(SpaceWars game) {
        this.actions(game);
    }
    
    @Override
    public Image getImage() {
        if(this.shield)
        	return GameGUI.SPACESHIP_IMAGE_SHIELD;
        return GameGUI.SPACESHIP_IMAGE;
    }
    
    /**
     * does the moving action for doAction method
     * @param game the game object to which this ship belongs.
     */
    protected void moveAction(SpaceWars game) {
        int pressed=DONT_TURN;
        boolean accel=game.getGUI().isUpPressed();
        if(game.getGUI().isRightPressed()){
            pressed=TURN_RIGHT;
        }
        if(game.getGUI().isLeftPressed()){
            pressed=TURN_LEFT;
        }
        this.pos.move(accel, pressed);
    }
    
    /**
     * Does the actions of this ship for this round. 
     * This is called once per round by the SpaceWars game driver.
     * @param game the game object to which this ship belongs.
     */
    protected void actions(SpaceWars game){
    	this.turnShieldOff();
    	//checks if t is pressed and try to teleport
    	if (game.getGUI().isTPressed() && this.energy>=TELEPORT_ENERGY)
        	this.teleport();
        moveAction(game);
        //checks if d is pressed and try to turn shield on
        if(game.getGUI().isDPressed())
            this.turnShieldOn();
        //checks if s is pressed and try to shoot
        if(game.getGUI().isSPressed())
        	shotCounter=this.shooting(game,shotCounter);
        this.setEnergy(REGAINED_ENERGY);
}
}